package com.efuture.servlet.request.sharedata;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

/**
 * @description: 演示request域数据共享
 * @author zhaoshanshan
 * @date 2021/10/2 11:51 下午
 * @version 1.0
 */
@WebServlet("/RequestShareDataTestOne")
public class RequestShareDataTestOne extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //设置值
        request.setAttribute("test","我是共享数据");
        System.out.println("RequestShareDataTestOne被访问了");
        //将请求转发
        request.getRequestDispatcher("/RequestShareDataTestTwo").forward(request,response);

    }
}
